package com.miao.hong.fang.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class ContextPathTag extends TagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4652631644872437493L;
	private String name;
	
	public void setName(String sName) throws JspException {
        this.name = EvalHelper.evalString("name", sName, this, pageContext);
    }

	public int doStartTag() {
		
		JspWriter out = pageContext.getOut();
		String contextPath = null;
		
		if("contextPath".equals(name)) {
			
			contextPath = ((HttpServletRequest) pageContext.getRequest()).getContextPath();
		}
		
		try {
			out.print(contextPath);	
		}catch (Exception e) {
			
		}		
		
		return SKIP_BODY;
	}
}
